﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CommonLibrary
{
    public class DictionnaryRepository
    {
        /// <summary>
        /// Gets the Dictionnary for the given type.
        /// </summary>
        /// <param name="Type"></param>
        /// <returns></returns>
        public IResourceDictionnary GetDictionnary<T>()
        {
            return _dictionnary[typeof(T)];
        }
        /// <summary>
        /// Register a dictionnary for the given key type.
        /// </summary>
        /// <param name="Type"></param>
        /// <param name="Dictionnary"></param>
        public void RegisterDictionnary<T>(IResourceDictionnary Dictionary)
        {
            _dictionnary.Add(typeof(T), Dictionary);
        }
        /// <summary>
        /// Gets a value from the dictionnary of the given type.
        /// </summary>
        /// <typeparam name="T">The dictionnary type.</typeparam>
        /// <param name="Key">THe object key.</param>
        /// <returns>The object.</returns>
        public T Get<T>(string Key)
        {
            var d = _dictionnary[typeof(T)];
            return (T)d.RawGet(Key);
        }

        private Dictionary<Type, IResourceDictionnary> _dictionnary = new Dictionary<Type, IResourceDictionnary>();
    }
}
